package com.zbkj.service.dividend.controller;

import com.zbkj.service.dividend.model.DividendPoolRecord;
import com.zbkj.service.dividend.request.DividendPoolRecordRequest;
import com.zbkj.service.dividend.service.DividendPoolRecordService;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.result.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户分红记录 前端控制器
 */
@Slf4j
@RestController
@RequestMapping("api/admin/dividendPool/record")
@Api(tags = "分红管理 -- 分红记录")
public class DividendPoolRecordController {

    @Autowired
    private DividendPoolRecordService dividendPoolRecordService;

    /**
     * 分页显示用户分红记录
     * @param request 查询条件
     * @param pageParamRequest 分页参数
     */
    @ApiOperation(value = "分页列表")
    @RequestMapping(value = "/list")
    public CommonResult<CommonPage<DividendPoolRecord>> getList(
            @Validated DividendPoolRecordRequest request,
            @Validated PageParamRequest pageParamRequest) {

        List<DividendPoolRecord> records = dividendPoolRecordService.getList(request, pageParamRequest);
        CommonPage<DividendPoolRecord> recordCommonPage = CommonPage.restPage(records);
        return CommonResult.success(recordCommonPage);
    }

}